package ru.payment.wm.impl;

import org.dom4j.Element;
import ru.payment.wm.Message;

/**
 *
 * User: sergey
 * Date: 22.04.2009
 * Time: 21:07:42
 *
 */
public class MessageParser extends AbstractResponseParser<Message, Element> {

  public void parse(Element e, Message msg) throws ProtocolException {
    if (e == null) {
      return;
    }

    msg.setMessageId(e.attributeValue("id"));

    msg.setReceiverWmId(asString(e.element("receiverwmid"), ""));
    msg.setMessageSubject(asString(e.element("msgsubj"), ""));
    msg.setMessageText(asString(e.element("msgtext"), ""));

    msg.setCreateDate(asDate(e.element("datecrt"), "yyyyMMdd HH:mm:ss"));
  }

}
